<?php  

//设计模式 简单工厂
 
class Mysql{
	
}
class Sqlite{
	
}
 
class Factroy{
	public static function getDB($type){
		if($type == "mysql"){
			return new mysql();
		}else if($type == "sqlite"){
			return new sqlite();
		}else{
			throw new Exception("sorry",1);
		}
	}
}
 
//获取Db对象
print_r(Factroy::getDB('mysql'));
 


















?>  